﻿using System;
using System.Collections.Generic;
using ContractManager.Entity;
using Speed.Data;

namespace ContractManager.BLL.Business
{
    public static class ClsResources
    {
        public static List<Resources> SelectAll()
        {
            using (var db = Sys.NewDb())
            {
                return Data.Base.Resources.Select(db);
            }
            
        }

        public static void Insert(Resources capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Insert<Resources>(capital, EnumSaveMode.Requery);
            }
           
        }

        public static void Update(Resources capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Update<Resources>(capital);
            }
            
        }

        public static Resources SelectByPk(Int32 resId)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<Resources>(string.Format("ResId={0}", resId));
            }
            
        }

        public static Resources SelectByCode(string resCode)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<Resources>(string.Format("ResCode='{0}'", resCode));
            }
            
        }

        public static int DeleteByPk(Int32 resId)
        {
            using (var db = Sys.NewDb())
            {
                return db.Delete<Resources>(string.Format("ResId={0}", resId));
            }
            
        }
    }
}
